/*******************************************************************
 *
 * Copyright (C), 2021-2022, LS, All rights reserved.
 *
 * Author      : 
 * Create Time : 2021-09-18
 * Version     : v0.1
 * Description : 
 *******************************************************************/
 
/*----------------------------Head file----------------------------*/
#include "OSAL.h"
#include "sys_task.h"
#include "osal_app.h"

/*----------------------------macro file---------------------------*/
#define SYS_TASK_LOG_EN     0

#if SYS_TASK_LOG_EN
#include "log.h"
#define SYS_TASK_LOG        LOG
#else
#define SYS_TASK_LOG(...)
#endif

/*----------------------------type define--------------------------*/

/*----------------------------var define---------------------------*/

/*-------------------------func declaration------------------------*/
extern void sys_ui_evt_handle(uint8_t evt);
extern void sys_background_evt_handle(uint8_t evt);

/*-----------------------------------------------------------------*/

void sys_task_msg_send(uint8_t type, uint8_t evt)
{
    // Allocate, build and send event
    sys_evt_t *pEvent = (sys_evt_t*)osal_msg_allocate((uint8_t)(sizeof(sys_evt_t)));
    if(pEvent) {
        pEvent->msg_type = type;
        pEvent->evt = evt;
        VOID osal_msg_send(osalApp_TaskID, (uint8_t*)pEvent);
    }
}


void sys_task_handle(sys_evt_t* pMsg)
{
    if(MSG_TYPE_UI == pMsg->msg_type) {
        sys_ui_evt_handle(pMsg->evt);
    }
    else if(MSG_TYPE_BG == pMsg->msg_type) {
        sys_background_evt_handle(pMsg->evt);
    }
}

